<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = [2, 1, 0, 4, 5, 6]
        let zong
        for (let i = 0; i < arr.length; i++) {
            if (arr[i] === 3) {
                zong = i
                break
            }
        }
        if (zong !== undefined) {
            document.write(`该元素的下标是${zong}`)
        }
        else {
            document.write(`未找到该元素`)
        }

    </script>
</body>

</html>